#include <stdio.h>
int main(){
    int m,n;
    scanf("%d %d",&n,&m);
    int a[1000];
    int count=0;
    char c;
    int num;
    while (1){
        scanf("%d",&num);
        a[count]=num;
        count++;
        if (getchar()=='\n'){
            break;
        }
        
    }

    int temp;
    for (int i=0;i<m;i++){
        temp=a[0];
        for (int j=0;j<n-1;j++){
            a[j]=a[j+1];
        }
        a[n-1]=temp;
    }
    for (int i=0;i<count;i++){printf("%d ",a[i]);}
    
    return 0;
}